<?php
namespace Home\Common;

class ChannelCharge extends Mysql{
	private $members;
	function __construct(){
		$this->members=array();
		parent::__construct();
	}
	function loadMembers($date,$channelid){
		$date=date("Y-m-d",strtotime($date));
		
		$result=$this->mysql->prepare("select thedate,count(distinct(userid)),count(userid),sum(sum) 
				from mog_charge where channelid=$channelid and thedate = \"$date\"");
		$result->execute();
		
		while($row=$result->fetch(\PDO::FETCH_ASSOC)){
			if($row['thedate']==""){$row['thedate']=$date; $row['count(distinct(userid))']=0; $row['count(userid)']=0; $row['sum(sum)']=0;}
			array_push($this->members,array($row['thedate'],$row['count(distinct(userid))'],$row['count(userid)'],$row['sum(sum)']));
		}
		
	}
	function getMembers(){
		$html	=	"";
		
		foreach($this->members as $v){
			$html.= "<tr><td>".substr($v[0],0,10)."</td><td>".$v[1]."</td><td>".$v[2]."</td><td>".$v[3]."</td></tr>";
		}
		return $html;
	}
}